﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.SqlClient;
using System.Data.Common;

public partial class LoginPasswordAdd : System.Web.UI.Page
{
    Microsoft.Practices.EnterpriseLibrary.Data.Database db = DatabaseFactory.CreateDatabase("Application_Data");

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Convert.ToBoolean(Session["sAdministrator"].ToString()) == false)
            {
                Response.Redirect("~/AccessDenied.aspx");
            }
        }
    }
    protected void btnAddLogin_Click(object sender, EventArgs e)
    {
        DbCommand dbCommand = db.GetSqlStringCommand("iuLoginPassword " +
                                           "@Login='" + this.txtLogin.Text + "'," +
                                           "@Description='" + this.txtDescription.Text + "'," +
                                           "@Password='" + this.txtPassword.Text + "'");

        db.ExecuteNonQuery(dbCommand);

        Response.Redirect("~/LoginPasswordList.aspx");
    }
}
